package com.yq.ylmall.acl.controller;

import com.yq.ylmall.acl.service.RoleMenuService;
import com.yq.ylmall.dto.acl.AssignMenuDto;
import com.yq.ylmall.result.Result;
import com.yq.ylmall.result.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 角色管理
 */
@RestController
@RequestMapping("/admin/system/roleMenu")
@Api(tags = "角色分配菜单管理")
public class RoleMenuController{
    @Autowired
    private RoleMenuService sysRoleMenuService ;

    @ApiOperation(value = "查询对应角色的菜单")
    @GetMapping(value = "/findSysRoleMenuByRoleId/{roleId}")
    public Result<Map<String , Object>> findSysRoleMenuByRoleId(@PathVariable(value = "roleId") Long roleId) {
        Map<String , Object> sysRoleMenuList = sysRoleMenuService.findSysRoleMenuByRoleId(roleId) ;
        return Result.build(sysRoleMenuList , ResultCode.SUCCESS) ;
    }

    @ApiOperation(value = "分配菜单")
    @PostMapping("/doAssign")
    public Result doAssign(@RequestBody AssignMenuDto assignMenuDto) {
        sysRoleMenuService.doAssign(assignMenuDto);
        return Result.build(null , ResultCode.SUCCESS) ;
    }
}
